"use strict";
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable("RolesMenus", {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER.UNSIGNED,
        comment: "ID",
      },
      roleId: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        comment: "角色ID",
      },
      menuId: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        comment: "菜单ID",
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE,
        comment: "创建时间",
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE,
        comment: "更新时间",
      },
    });
    await queryInterface.addIndex("RolesMenus", {
      fields: ["roleId"],
    });
    await queryInterface.addIndex("RolesMenus", {
      fields: ["menuId"],
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable("RolesMenus");
  },
};
